Skip to content

DataViews: Store the clicked calendar day in the datetime control across timezones - #81637

Closed
jorgefilipecosta wants to merge 2 commits into
trunkfrom
fix/dataviews-datetime-calendar-day-timezone
Closed

jorgefilipecosta wants to merge 2 commits into
trunkfrom
fix/dataviews-datetime-calendar-day-timezone

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Aug 14, 2026 •

Copy link
Copy Markdown
Member

When the site timezone is behind the timezone the calendar is rendered in, clicking a day in the Datetime DataForm control's calendar stores the previous day. The calendar hands back the clicked day as a Date built from its displayed day, and converting that instant with dateI18n( 'Y-m-d', … ) re-expresses it in the site timezone, shifting it across midnight. For example, with the site timezone at UTC and a browser at UTC+1, clicking "October 14" stores October 13.

The fix reads the selected day through the date's own fields with format( newDate, 'yyyy-MM-dd' ), the same way the plain date control already reads its selections, and uses the start of the selected day as the fallback when there is no time to preserve. The time of an existing value is still preserved in the site timezone.

Discovered while preparing #81635. A broader follow-up worth considering separately: for sites configured with a manual offset (no named timezone), the calendar's timeZone prop falls back to the browser timezone, so day highlighting and the "today" marker also render in the wrong frame across the date controls; rendering the calendar in the site timezone would need an offset-based timeZone value and has browser-compatibility implications, so it is intentionally out of scope here.

Testing Instructions

  1. Make sure the site timezone differs from your browser's, with the site behind — for example set the site to UTC+0 (or an offset like UTC-5) in Settings > General while your machine is ahead of it.
  2. Enable the DataForm inspector experiment under Gutenberg > Experiments ("Block fields: Show dataform driven inspector fields on blocks that support them").
  3. Open a post in the editor, open the Settings sidebar, and click the Date field.
  4. Click a day in the calendar. The datetime input above the calendar (and the value shown in the sidebar) should show the day you clicked. Without this change, they show the previous day.

The unit test can be run with:

npm run test:unit -- packages/dataviews/src/components/dataform-controls/test

Before (video): clicking October 14 stores October 13.

After (video): clicking October 14 stores October 14.

Note: this branch and #81635 both touch datetime.tsx and add to the same test file, so whichever lands second needs a trivial rebase.


AI tools were used to assist in the preparation of this PR.

@github-actions

Copy link
Copy Markdown

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: .

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions

github-actions Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions github-actions Bot added the [Package] DataViews /packages/dataviews label Aug 14, 2026
@github-actions

github-actions Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Size Change: +23 B (0%)

Total Size: 7.74 MB

📦 View Changed
Filename Size Change
build/scripts/block-editor/index.min.js 470 kB -6 B (0%)
build/scripts/edit-site/index.min.js 335 kB +11 B (0%)
build/scripts/editor/index.min.js 532 kB +10 B (0%)
build/scripts/media-utils/index.min.js 154 kB +8 B (+0.01%)

compressed-size-action

@jorgefilipecosta
jorgefilipecosta force-pushed the fix/dataviews-datetime-calendar-day-timezone branch from ca84176 to 6cee1c2 Compare August 19, 2026 17:17
@github-actions

Copy link
Copy Markdown

Flaky tests detected in 6cee1c2.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/32280805629
📝 Reported tests:

Should save the changes in /test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js, passed after 2 failed attempts.
TimeoutError: page.waitForFunction: Timeout 10000ms exceeded.
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js:34:14
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=button[name="Visual"i]')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js:33:55
edits a scope guideline after a reload in /test/e2e/specs/admin/guidelines.spec.js, passed after 1 failed attempt.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → GET http://localhost:8889/wp-json/wp/v2/knowledge?per_page=100&context=edit&status=publish%2Cdraft%2Cprivate
    - user-agent: Playwright/1.62.1 (x64; ubuntu 24.04) node/20.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 2ac0306aad
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1787332965%7CziwrJON5AK9zvfrdrPuRsc06XLb4bzVX15wTnzhHYQW%7C1103b247d6d6e1aa8ad847ad09b28bb6c8058be1c4b9225a4d55d0cb6607dee1; wp-settings-time-1=1787160166

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:112:39)
    at deleteAllGuidelines (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/admin/guidelines.spec.js:12:34)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/admin/guidelines.spec.js:100:9
should allow user to add and remove multiple local font files in /test/e2e/specs/admin/font-library.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByLabel('Exo 2 Semi-bold Italic')
Expected: visible
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" with timeout 5000ms
  - waiting for getByLabel('Exo 2 Semi-bold Italic')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/admin/font-library.spec.js:58:6

@ciampo

ciampo commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by #81498 (which should cover the same fix + additional improvements).

@jorgefilipecosta please check #81498 and feel free to re-open this PR in case I misinterpreted

@ciampo ciampo closed this Aug 22, 2026
@oandregal
oandregal deleted the fix/dataviews-datetime-calendar-day-timezone branch August 24, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] DataViews /packages/dataviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants